package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.MallBooksDO;
import com.starlink.model.request.MallBooksRequest;
import com.starlink.model.request.mall.EntryData;
import com.starlink.model.request.mall.MallSearchRequest;
import com.starlink.model.vo.MallBooksVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author zhanghong
 */
@Repository
public interface MallBooksMapper extends BaseMapper<MallBooksDO> {
    MallBooksDO selectDOById(Long id);
    List<MallBooksDO> selectDOList(MallBooksDO mallBooks);
    int insertDO(MallBooksDO mallBooks);
    int batchInsertDO(List<MallBooksDO> mallBooksDOList);
    int updateDO(MallBooksDO mallBooks);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from mall_books",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") MallBooksRequest param);

    List<MallBooksVO> pageQuery(@Param("param") MallBooksRequest param, @Param("limit") int limit, @Param("offset") long offset);

    List<MallBooksVO> pagingQuery(MallBooksRequest request);

    List<MallBooksDO> selectRandomBooks(@Param("mallBooksId") Long mallBooksId);

    List<MallBooksDO> queryByGroupBagId(Long schoolbagGroupBagId);

    void batchUpdate(List<EntryData> list);

}
